<!DOCTYPE html>
<html lang="zh">
<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width, initial-scale=1.0">
    <title>ThreeCloud</title>
    <style>
        body {
            font-family: Arial, sans-serif;
            margin: 20px;
        }
        button {
            padding: 10px 20px;
            font-size: 16px;
            cursor: pointer;
        }
        .log {
            margin-top: 20px;
            max-height: 300px;
            overflow-y: auto;
            border: 1px solid #ccc;
            padding: 10px;
        }
    </style>
</head>
<body>
    <h1>ThreeCloudTestDemo</h1>
    <button onclick="batchRequest(10)">POST</button>
    <div class="log" id="log"></div>

    <script>
        const data = {
            auth: "d38325db74a420d1dcbe9ddc48da54a6",
            s2t: 1735263098,
            version: "1.43.1",
            uin: 230230112,
            ts: 1735263139,
            aid: 21689852366078,
            appid: 1000
        };

        const headers = {
            'Content-Type': 'application/x-www-form-urlencoded;charset=UTF-8'
        };

        function sendPostRequest() {
            return fetch('https://cs-gsmgr.mini1.cn/v2/room/get', {
                method: 'POST',
                headers: headers,
                body: new URLSearchParams(data)
            })
            .then(response => {
                if (!response.ok) {
                    throw new Error('请求错误: ' + response.statusText);
                }
                return response.json();
            })
            .then(responseData => {
                logMessage('开启成功! ' + JSON.stringify(responseData));
            })
            .catch(error => {
                logMessage('请求错误: ' + error.message);
            });
        }

        function batchRequest(numRequests) {
            const requests = [];
            for (let i = 0; i < numRequests; i++) {
                requests.push(sendPostRequest());
            }
            Promise.all(requests).then(() => {
                logMessage('所有请求已完成');
            });
        }

        function logMessage(message) {
            const logDiv = document.getElementById('log');
            const messageElement = document.createElement('div');
            messageElement.textContent = message;
            logDiv.appendChild(messageElement);
        }
    </script>
</body>
</html>